from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (GoodsViewSet, CustomerViewSet, SalesOrderViewSet,
                    InventoryViewSet, UserViewSet, UserRegistrationView,
                    CustomLoginView, ReportViewSet)
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)

router = DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'goods', GoodsViewSet)
router.register(r'inventory', InventoryViewSet)
router.register(r'sales/orders', SalesOrderViewSet)
router.register(r'customers', CustomerViewSet)
router.register(r'reports', ReportViewSet)

urlpatterns = [
    path('', include(router.urls)),
    path('register/', UserRegistrationView.as_view(), name='user-register'),
    # 自定义登录视图路径
    path('login/', CustomLoginView.as_view(), name='token_obtain_pair'),
    path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]
